﻿using System;
using System.Diagnostics;
using KuiHuaBaoDian.Services.Lockstep;

namespace Runtime.Services.Battle.Entity {

    /// <summary>
    /// 战斗实体句柄
    /// </summary>
    [DebuggerStepThrough]
    [DebuggerNonUserCode]
    public readonly struct DFR_BattleEntityHandle {

        public static readonly DFR_BattleEntityHandle Empty = new();

        /// <summary>
        /// 实例ID
        /// </summary>
        public DFR_BattleEntityInstanceID EntityInstanceID { get; init; }

        /// <summary>
        /// 帧同步实体句柄
        /// </summary>
        public LockstepEntityHandle LockstepEntityHandle { get; init; }

        public override int GetHashCode() => HashCode.Combine(EntityInstanceID, LockstepEntityHandle);

        public override bool Equals(object obj) {
            if (obj is DFR_BattleEntityHandle other) {
                return other.EntityInstanceID == EntityInstanceID && other.LockstepEntityHandle == LockstepEntityHandle;
            }
            return false;
        }

        public static bool operator ==(DFR_BattleEntityHandle left, DFR_BattleEntityHandle right) => left.Equals(right);
        public static bool operator !=(DFR_BattleEntityHandle left, DFR_BattleEntityHandle right) => !left.Equals(right);
    }
}
